if [ -f "$HOME/.livebookdesktop.sh" ]; then
  . "$HOME/.livebookdesktop.sh"
fi

export RELEASE_MODE="interactive"
if [ -z "${RELEASE_DISTRIBUTION}" ]; then export RELEASE_DISTRIBUTION="none"; fi

vendor_dir="${RELEASE_ROOT}/vendor/livebook-${RELEASE_VSN}"
export MIX_ARCHIVES="${vendor_dir}/archives"
export MIX_REBAR3="${vendor_dir}/rebar3"
export LIVEBOOK_SHUTDOWN_ENABLED=${LIVEBOOK_SHUTDOWN_ENABLED:-true}
[ -z "$LIVEBOOK_PORT" ] && export LIVEBOOK_PORT=32123
export PATH="${vendor_dir}/otp/erts-<%= @release.erts_version%>/bin:${vendor_dir}/otp/bin:${vendor_dir}/elixir/bin:$PATH"

if [ ! -z "${LIVEBOOK_NODE}" ]; then export RELEASE_NODE=${LIVEBOOK_NODE}; fi
if [ ! -z "${LIVEBOOK_COOKIE}" ]; then export RELEASE_COOKIE=${LIVEBOOK_COOKIE}; fi

export RELEASE_COOKIE="${RELEASE_COOKIE:-$(head -c 512 /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)}"

cd $HOME
